<template>
  <div class="Hits">
    <div class="top">
      <span @click="returngo">🎁</span>
      <span>人气推荐</span>
      <span> </span>
    </div>
    <div class="content">
      <ul>
        <li
          v-for="(item, index) in list"
          :key="index"
          @click="gotohitsshop(item.id)"
        >
          <div class="img">
            <img :src="item.pic" alt="" />
            <div class="text">
              <p v-html="item.name"></p>
              <p v-html="item.characteristic" class="texts"></p>
              <p class="color">{{ "￥" + item.originalPrice }}</p>
            </div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import { getHitss } from "../../utils/api";
export default {
  data() {
    return {
      list: [],
    };
  },
  mounted() {
    getHitss().then((res) => {
      console.log(res);
      this.list = res.data;
    });
  },
  methods: {
    //去到人气商品详情
    gotohitsshop(id) {
      console.log(id);
      this.$router.push({ path: "/hitsdetail", query: { id: id } });
    },
    //返回
    returngo() {
      this.$router.go(-1);
    },
  },
};
</script>

<style lang="scss" scoped>
.top {
  width: 100%;
  height: 1rem;
  display: flex;
  justify-content: space-around;
  font-size: 0.35rem;
  line-height: 1rem;
  border-bottom: 1px solid #cccccc;
}
.content {
  width: 100%;
  height: 15rem;
  overflow: auto;
  ul {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    li {
      margin-top: 0.2rem;
      .img {
        height: 5rem;
        // background: red;
        img {
          width: 3.5rem;
          height: 4rem;
        }
        .text {
          width: 100%;
          height: 1rem;
          .color {
            color: red;
          }
          .texts {
            width: 3rem;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
        }
      }
    }
  }
}
</style>
